package cn.oa.service.Impl;



import cn.oa.dao.DepartmentDao;
import cn.oa.dao.EmployeeDao;
import cn.oa.entity.Department;
import cn.oa.service.DepartmentService;
import cn.oa.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.sql.SQLException;
import java.util.List;

public class DepartmentServiceImpl implements DepartmentService {

    SqlSessionFactory sqlSessionFactory = MybatisUtil.sessionFactory;
    @Override
    public List<Department> getAllDepartments() throws SQLException {
        SqlSession sqlSession = sqlSessionFactory.openSession();

        DepartmentDao departmentDao = sqlSession.getMapper(DepartmentDao.class);
        List<Department> list = departmentDao.getAllDepartments();
        sqlSession.close();
        return list;
    }
}

